package com.wang.rabbitmq.directmq;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.TimeoutException;

/**
 * @author: wang
 * @date: 2021/8/3 15:33
 * @description:
 */
public class MySendDirectMq {
    public static void main(String[] args) throws IOException, TimeoutException {
        ConnectionFactory factory = new ConnectionFactory();
        factory.setPort(5672);
        factory.setHost("192.168.169.123");
        factory.setUsername("root");
        factory.setPassword("root");
        factory.setVirtualHost("/");
        Connection connection = factory.newConnection();
        Channel channel = connection.createChannel();
        channel.exchangeDeclare("driectExchange01", "direct");
        channel.queueDeclare("directQueue01", true, false,false,null);
        channel.basicPublish("driectExchange01", "direct01", null, "你大爷始终是你大爷".getBytes(StandardCharsets.UTF_8));
        channel.close();
        connection.close();
    }
}
